package com.sugar.subscribe.course.module.business.controller.app.venue;

import com.sugar.subscribe.course.framework.common.pojo.CommonResult;
import com.sugar.subscribe.course.module.business.controller.admin.venue.vo.VenueSimpleRespVO;
import com.sugar.subscribe.course.module.business.service.venue.VenueService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;

import static com.sugar.subscribe.course.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 场地")
@RestController
@RequestMapping("/biz/venue")
@Validated
public class AppVenueController {

    @Resource
    private VenueService venueService;

    @GetMapping("/all")
    @Operation(summary = "获得所有场地")
    @PermitAll
    public CommonResult<List<VenueSimpleRespVO>> getVenueAll() {
        return success(venueService.getVenueAll());
    }

    @GetMapping("/list/{cityId}")
    @Operation(summary = "根据城市ID获得该城市场地")
    @PermitAll
    public CommonResult<List<VenueSimpleRespVO>> getVenuesByCityId(@PathVariable("cityId") Long cityId) {
        return success(venueService.getVenuesByCityId(cityId));
    }
}
